package com.glory.dgcpcpda.adapter;

import android.view.View;
import android.widget.CheckBox;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.dgcpcpda.R;
import com.glory.dgcpcpda.entity.ChangeShiftEntity;
import com.glory.dgcpcpda.entity.EqpAlarmRelease;

import java.util.ArrayList;
import java.util.List;

/**
 * FileName: ChangeShiftsAdapter
 * Author: XJH
 * Date: 2020/7/1 19:31
 * Description:
 * History:
 */
public class EqpAlarmReleaseAdapter extends BaseQuickAdapter<EqpAlarmRelease, BaseViewHolder> {

    public List<EqpAlarmRelease> releaseData;

    public EqpAlarmReleaseAdapter(@Nullable List<EqpAlarmRelease> data) {
        super(R.layout.item_eqp_alarm_release_adapter,data);
        releaseData = new ArrayList<>();
    }

    @Override
    protected void convert(BaseViewHolder helper, EqpAlarmRelease item) {
        helper.setText(R.id.tveqpId,item.getEQP_NO())
                .setText(R.id.tvLot,item.getALARM_CODE())
                .setText(R.id.tvMaterialBox,item.getALARM_TIME())
                .setText(R.id.tvdesc,item.getEqpCmdParam());
        helper.getView(R.id.tveqpId).setVisibility(View.GONE);
        CheckBox checkbox = helper.getView(R.id.checkbox);

        checkbox.setChecked(false);
        checkbox.setOnCheckedChangeListener((compoundButton, b) -> {
            if (b){
                releaseData.add(item);
            }else {
                releaseData.remove(item);
            }
        });

    }

}
